﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HR.Appointments.Service.FacadeUsers;

namespace HR.Appointments.Service
{
    /// <summary>
    /// Enterance to the service layer should be through this class.
    /// </summary>
    public class ServiceFacade 
    {
        #region Constructors
        /// <summary>
        /// Creates a new serviceface
        /// </summary>
        /// <param name="initialize">If true then we load the database layer.  
        /// Set to False if using testing.</param>
        public ServiceFacade(bool initialize)
        {
            if (initialize)
            {
                DAO.Instance.DeInitialize();
                DAO.Instance.Initialize();
            }
        }
        #endregion

        #region Public Methods
        /// <summary>
        /// Get all companies that has not been deleted
        /// </summary>
        /// <returns>A list of companies</returns>
        public List<CompanyEntity> AvailableCompanies()
        {
            return DAO.Instance.Company.GetAll();
        }

        /// <summary>
        /// Search for specific companies that starts with or ends with name
        /// </summary>
        /// <param name="name">A company name to serach for</param>
        /// <returns>A list of companies</returns>
        public List<CompanyEntity> SearchCompaniesByName(string name)
        {
            return DAO.Instance.Company.GetByName(name);
        }
        #endregion

        #region Public Facade Users Methods
        /// <summary>
        /// Access to user methods
        /// </summary>
        /// <returns>A new user object</returns>
        public User Anonymous()
        {
            return new User();
        }

        /// <summary>
        /// Access to employee methods
        /// </summary>
        /// <returns>A new employee object</returns>
        public Employee Employee()
        {
            return new Employee();
        }

        /// <summary>
        /// Access to administrator methods
        /// </summary>
        /// <returns>A new owner object</returns>
        public Owner Administrator()
        {
            return new Owner();
        }

        /// <summary>
        /// Access to notification methods
        /// </summary>
        /// <returns>A new notification object</returns>
        public Notifier Notify()
        {
            return new Notifier();
        }
        #endregion

    }
}
